package nz.ac.massey.doi_information_extractor.data;


public class Author {
	private int authorId;
	private String authorFirstName;
	private String authorLastName;
	private String organisation;
	private String department;
	private String authorType;
	private String userId;

	public Author(){
		authorId = -1;
		authorFirstName = "";
		authorLastName = "";
		organisation = "";
		department = "";
		authorType = "";
		userId = "";
	}

	/**
	 * @param authorID the unique ID for an author.
	 * @param author_f_name the authors first name.
	 * @param author_l_name the authors last name.
	 * @param organisation the organisation the author is attached to.
	 * @param department the department of the organisation the author belongs to.
	 * @param authorType states whether a user is internal,external or a student.
	 * @parm userId the staff/student/? id of the user
	 */
	public Author(int authorID, String author_f_name, String author_l_name, String organisation, String department, String authorType, String userId){
		this.authorId = authorID;
		this.authorFirstName = author_f_name;
		this.authorLastName = author_l_name;
		this.organisation = organisation;
		this.department = department;
		this.authorType = authorType;
		this.userId = userId;
	}

	/**
	 * @param authorStaffID a place to put the Massey ID of an author.
	 * @param author_f_name the authors first name.
	 * @param author_l_name the authors last name.
	 * @param organisation the organisation the author is attached to.
	 * @param department the department of the organisation the author belongs to.
	 * @param authorType states whether a user is internal,external or a student.
	 * @param userId the staff/student/? id of the author.
	 */
	public Author(String author_f_name, String author_l_name, String organisation, String department, String authorType, String userId){
		this.authorId = -1;
		this.authorFirstName = author_f_name;
		this.authorLastName = author_l_name;
		this.organisation = organisation;
		this.department = department;
		this.authorType = authorType;
		this.userId = userId;
	}

	public int getAuthorId(){
		return authorId;
	}

	public void setAuthorId(int authorId){
		this.authorId = authorId;
	}


	public String getAuthorFirstName(){
		return authorFirstName;
	}


	public void setAuthorFirstName(String authorFirstName){
		this.authorFirstName = authorFirstName;
	}

	public String getAuthorLastName(){
		return authorLastName;
	}


	public void setAuthorLastName(String authorLastName){
		this.authorLastName = authorLastName;
	}

	public String getOrganisation(){
		return organisation;
	}

	public void setOrganisation(String organisation){
		this.organisation = organisation;
	}

	public String getDepartment(){
		return department;
	}

	public void setDepartment(String department){
		this.department = department;
	}

	public String getAuthorType(){
		return authorType;
	}

	public void setAuthorType(String authorType){
		this.authorType = authorType;
	}

	public String getUserId(){
		return userId;
	}

	public void setUserId(String userId){
		this.userId = userId;
	}
	public boolean equalsFull(Author author){

		if(this == author)
			return true;

		if(author == null)
			return false;

		if(getClass() != author.getClass())
			return false;

		if(authorId != -1 && author.getAuthorId() != -1 && authorId == author.getAuthorId())
			return true;

		if(authorId != -1 && author.getAuthorId() != -1 && authorId != author.getAuthorId())
			return false;

		if(!authorFirstName.equals(author.getAuthorFirstName()))
			return false;

		if(!authorLastName.equals(author.getAuthorLastName()))
			return false;

		if(!authorType.equals(author.getAuthorType()))
			return false;

		if(!department.equals(author.getDepartment()))
			return false;
		
		if(!userId.equals(author.getUserId()))
			return false;

		if(organisation.equals(author.getOrganisation()))
			return false;

		return true;

	}

	public boolean equals(Author author){

		if(this == author)
			return true;

		if(author == null)
			return false;

		if(getClass() != author.getClass())
			return false;

		if(authorId != -1 && author.getAuthorId() != -1 && authorId == author.getAuthorId())
			return true;

		return false;
	}
}
